package psn.kiko.service.business.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import psn.kiko.pojo.dto.TextMailDTO;

/**
 *SMTP邮件服务
 */
@Service
public class EmailService{
	@Value("${spring.mail.username}")
	private String mailSentFrom;
	
	@Autowired
	JavaMailSender javaMailSender;
	
	public void sendTextEmail(TextMailDTO textMailDTO){
		SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
		simpleMailMessage.setFrom(mailSentFrom);
		simpleMailMessage.setTo(textMailDTO.getMailSentTo());
//		抄送
//		simpleMailMessage.setCc(from);
		simpleMailMessage.setSubject(textMailDTO.getMailSubject());
		simpleMailMessage.setText(textMailDTO.getMailContent());
		javaMailSender.send(simpleMailMessage);
	}
}
